home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-04-25 | 9.7 KB | 346 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWViewAs.cpp
- // Release Version: $ ODF 1 $
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #include "FWFrameW.hpp"
-
- #ifndef FWVIEWAS_H
- #include "FWViewAs.h"
- #endif
-
- #ifndef FWSTDDEF_H
- #include "FWStdDef.h"
- #endif
-
- #ifndef FWCONTXT_H
- #include "FWContxt.h"
- #endif
-
- #ifndef FWPRESEN_H
- #include "FWPresen.h"
- #endif
-
- // ----- OS Layer -----
-
- #ifndef FWRECSHP_H
- #include "FWRecShp.h"
- #endif
-
- #ifndef FWPOLY_H
- #include "FWPoly.h"
- #endif
-
- #ifndef FWPOLYSH_H
- #include "FWPolySh.h"
- #endif
-
- #ifndef FWREGION_H
- #include "FWRegion.h"
- #endif
-
- #ifndef FWBMPSHP_H
- #include "FWBmpShp.h"
- #endif
-
- #ifndef FWCFMRES_H
- #include "FWCFMRes.h"
- #endif
-
- #ifndef FWRECT_H
- #include "FWRect.h"
- #endif
-
- #ifndef FWICONSH_H
- #include "FWIconSh.h"
- #endif
-
- #ifndef FWODGEOM_H
- #include "FWODGeom.h"
- #endif
-
- #ifndef FWLINSHP_H
- #include "FWLinShp.h"
- #endif
-
- // ----- Framework Layer -----
-
- #ifndef FWFRAME_H
- #include "FWFrame.h"
- #endif
-
- #ifndef FWPART_H
- #include "FWPart.h"
- #endif
-
- #ifndef FWUTIL_H
- #include "FWUtil.h"
- #endif
-
- // ----- OpenDoc Includes -----
-
- #ifndef SOM_ODFacet_xh
- #include <Facet.xh>
- #endif
-
- // ----- Platform Includes -----
-
- #if defined(FW_BUILD_MAC) && !defined(__ICONS__)
- #include <Icons.h>
- #endif
-
- //========================================================================================
- // RunTime Info
- //========================================================================================
-
- #ifdef FW_BUILD_MAC
- #pragma segment fwpart2
- #endif
-
- //========================================================================================
- // CLASS FW_CViewAs
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // FW_CViewAs::FW_CViewAs
- //----------------------------------------------------------------------------------------
-
- FW_CViewAs::FW_CViewAs(Environment *ev) :
- fShape(NULL)
- {
- FW_UNUSED(ev);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CViewAs::~FW_CViewAs
- //----------------------------------------------------------------------------------------
-
- FW_CViewAs::~FW_CViewAs()
- {
- delete fShape;
- fShape = NULL;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CViewAs::Unload
- //----------------------------------------------------------------------------------------
-
- void FW_CViewAs::Unload(Environment* ev)
- {
- FW_UNUSED(ev);
- delete fShape;
- fShape = NULL;
- }
-
- //========================================================================================
- // CLASS FW_CViewAsThumbnail
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // FW_CViewAsThumbnail::FW_CViewAsThumbnail
- //----------------------------------------------------------------------------------------
-
- FW_CViewAsThumbnail::FW_CViewAsThumbnail(Environment *ev) :
- FW_CViewAs(ev)
- {
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CViewAsThumbnail::~FW_CViewAsThumbnail
- //----------------------------------------------------------------------------------------
-
- FW_CViewAsThumbnail::~FW_CViewAsThumbnail()
- {
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CViewAsThumbnail::Load
- //----------------------------------------------------------------------------------------
-
- void FW_CViewAsThumbnail::Load(Environment* ev, FW_CFrame* frame)
- {
- if (fShape == NULL)
- {
- fUsedRect.Set(FW_kZeroPoint, FW_IntToFixed(64), FW_IntToFixed(64));
-
- FW_CBitmap bitmap(64, 64, 8);
-
- {
- FW_CBitmapContext bc(ev, bitmap);
-
- FW_CRectShape::RenderRect(bc, fUsedRect, FW_kFill, FW_kWhiteEraseInk);
- FW_CRectShape::RenderRect(bc, fUsedRect, FW_kFrame);
- FW_CLineShape::RenderLine(bc, fUsedRect.TopLeft(), fUsedRect.BotRight());
- FW_CLineShape::RenderLine(bc, fUsedRect.BotLeft(), fUsedRect.TopRight());
-
- frame->BuildThumbnail(ev, bc, fUsedRect);
- }
-
- fShape = FW_NEW(FW_CBitmapShape, (bitmap, fUsedRect));
- }
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CViewAsThumbnail::CalcUsedShape
- //----------------------------------------------------------------------------------------
-
- ODShape* FW_CViewAsThumbnail::CalcUsedShape(Environment* ev) const
- {
- return ::FW_NewODShape(ev, fUsedRect);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CViewAsThumbnail::Draw
- //----------------------------------------------------------------------------------------
-
- void FW_CViewAsThumbnail::Draw(Environment* ev, FW_CFrame* frame, ODFacet* facet, ODShape* invalidShape)
- {
- Load(ev, frame);
-
- FW_CFrameContext fc(ev, facet, invalidShape);
- fShape->Render(fc);
-
- if (facet->GetHighlight(ev) != kODNoHighlight)
- {
- FW_CRect bounds = frame->GetVisibleBounds(ev);
- FW_CInk hilite(FW_kRGBBlack, FW_kRGBWhite, FW_kHilite);
- FW_CRectShape::RenderRect(fc, bounds, FW_kFill, hilite);
- }
- }
-
- //========================================================================================
- // CLASS FW_CViewAsIcon
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // FW_CViewAsIcon::FW_CViewAsIcon
- //----------------------------------------------------------------------------------------
-
- FW_CViewAsIcon::FW_CViewAsIcon(Environment *ev, short iconSize) :
- FW_CViewAs(ev),
- fIconSize(iconSize)
- {
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CViewAsIcon::~FW_CViewAsIcon
- //----------------------------------------------------------------------------------------
-
- FW_CViewAsIcon::~FW_CViewAsIcon()
- {
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CViewAsIcon::Draw
- //----------------------------------------------------------------------------------------
- // invalidShape is in Frame Coordinates
-
- void FW_CViewAsIcon::Draw(Environment* ev, FW_CFrame* frame, ODFacet* facet, ODShape* invalidShape)
- {
- Load(ev, frame);
-
- FW_RenderIconTransform iconTransform = FW_kIconTransformNone;
-
- if (facet->GetHighlight(ev) == kODFullHighlight )
- iconTransform = FW_kIconTransformSelected;
-
- // Check to see if the frame has been opened into a part window.
- FW_CWindow* window = frame->GetPresentation(ev)->GetPartWindow(ev);
- if (window && window->IsShown(ev) )
- iconTransform |= FW_kIconTransformOpen;
-
- ((FW_CIconShape*)fShape)->SetIconTransform(iconTransform);
-
- FW_CFrameContext fc(ev, facet, invalidShape);
- fShape->Render(fc);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CViewAsIcon::Load
- //----------------------------------------------------------------------------------------
-
- void FW_CViewAsIcon::Load(Environment* ev, FW_CFrame* frame)
- {
- if (fShape == NULL)
- {
- FW_CIcon icon = frame->GetIcon(ev, fIconSize);
-
- FW_CRect iconRect(FW_kZeroPoint, FW_IntToFixed(fIconSize), FW_IntToFixed(fIconSize));
- fShape = FW_NEW(FW_CIconShape, (icon, iconRect));
- }
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CViewAsIcon::CalcUsedShape
- //----------------------------------------------------------------------------------------
-
- ODShape* FW_CViewAsIcon::CalcUsedShape(Environment* ev) const
- {
- FW_ASSERT(fShape != NULL);
-
- #ifdef FW_BUILD_MAC
- FW_CIcon icon;
- FW_RenderIconAlignment alignment;
- FW_RenderIconTransform transform;
- FW_CRect rect;
- ((FW_CIconShape*)fShape)->GetGeometry(icon, rect, transform, alignment);
-
- RgnHandle rgn = ::NewRgn();
- FW_CPlatformRect bounds(0, 0, fIconSize, fIconSize);
- ::IconSuiteToRgn(rgn, &bounds, atNone, icon.GetPlatformIcon());
-
- return ::FW_NewODShape(ev, rgn);
- #endif
-
- #ifdef FW_BUILD_WIN
- FW_DEBUG_MESSAGE("Not yet implemented");
- #endif
- }
-
- //========================================================================================
- // CLASS FW_CViewAsSmallIcon
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // FW_CViewAsSmallIcon::FW_CViewAsSmallIcon
- //----------------------------------------------------------------------------------------
-
- FW_CViewAsSmallIcon::FW_CViewAsSmallIcon(Environment *ev) :
- FW_CViewAsIcon(ev, 16)
- {
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CViewAsSmallIcon::~FW_CViewAsSmallIcon
- //----------------------------------------------------------------------------------------
-
- FW_CViewAsSmallIcon::~FW_CViewAsSmallIcon()
- {
- }
-
- //========================================================================================
- // CLASS FW_CViewAsLargeIcon
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // FW_CViewAsLargeIcon::FW_CViewAsLargeIcon
- //----------------------------------------------------------------------------------------
-
- FW_CViewAsLargeIcon::FW_CViewAsLargeIcon(Environment *ev) :
- FW_CViewAsIcon(ev, 32)
- {
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CViewAsLargeIcon::~FW_CViewAsLargeIcon
- //----------------------------------------------------------------------------------------
-
- FW_CViewAsLargeIcon::~FW_CViewAsLargeIcon()
- {
- }
-
-